
// --------------------------------------------------------------------------
//
// Rocket launcher
//
// --------------------------------------------------------------------------

ACTOR AdvancedMissileLauncher : BrutalWeapon
{
	Game Doom
	Speed 20
	Damage 20
	Weapon.SelectionOrder 9500
	Weapon.PreferredSkin "RocketMarine"
	Weapon.AmmoUse1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	Weapon.AmmoGive1 6
	Weapon.AmmoType1 "AmmoRocket"
	Weapon.AmmoType2 "AMLRounds"
	Weapon.PreferredSkin "RL Marine"
    Inventory.PickupSound "ROCKPKUP"
    +WEAPON.NOAUTOAIM
	+FORCEXYBILLBOARD
	+WEAPON.AXEBLOOD
	+WEAPON.NO_AUTO_SWITCH
	Inventory.PickupMessage "You got the Advanced Grenade Launcher (Slot 5)!"
	Inventory.ForbiddenTo Sorcerer, Corvus
	States
	
	{
	
	/*PickUp:
	TNT1 A 0
	TNT1 A 0 A_Playsound("PICKUPONELINER")
	TNT1 A 0
	Stop*/
	
	Spawn:
		LAUN C -1
		Stop
		
	GoingToReady:
	TNT1 A 1
	Goto Ready
	Ready3:
	Ready:
		// This is placed here for now, should be moved if there is a replaying
		// idle animation for weapons
	ReadyLoop:
	    AMPG A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLG A 0
		"####" A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		"####" A 0 A_JumpIfInventory("Unloading",1,"Unload")
        "####" A 0 A_JumpIfInventory("Reloading",1,"Reload")
        "####" A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		"####" A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		"####" A 0 A_JumpIfInventory("Salute2", 1, "Salute")
        "####" A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		"####" A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
		"####" A 0 A_JumpIfInventory("HasUnloadedRL", 1, "ReadyNoAmmo")

		Loop
		
		
	ReadyNoAmmo:
		"####" A 0 A_JumpIfInventory("Unloading",1,"Unload")
        "####" A 0 A_JumpIfInventory("Reloading",1,"Reload")
        "####" A 0 A_JumpIfInventory("Kicking",1,"DoKick")
		"####" A 0 A_JumpIfInventory("Salute1", 1, "Salute")
		"####" A 0 A_JumpIfInventory("Salute2", 1, "Salute")
        "####" A 0 A_JumpIfInventory("Taunting",1,"Taunt")
		"####" A 0 A_JumpIfInventory("TossGrenade",1,"TossGrenade")
	    AMPR I 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLR I 0
		"####" I 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Loop	
	
	Deselect:
	    AMPG A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLG A 0
        //"####" FEDCBA 1
		"####" A 0 A_TakeInventory("TossGrenade", 1)
		//TNT1 AAAAAAAAAAAAAAAAAA 0 A_Lower
		"####" A 1 A_Lower
		Wait
		
	Select:
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 A_Takeinventory("HasBarrel",1)
		TNT1 A 0 A_TakeInventory("TossGrenade", 1)
	
		AMPG A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLG A 0
		"####" A 1 A_Raise
		Wait
	
	Fire:
        TNT1 A 0 A_JumpIfInventory("AMLRounds",1,2)
        Goto Reload
        TNT1 AAAA 0
		TNT1 A 0 A_TakeInventory ("HasUnloadedRL", 1)
		TNT1 A 0 A_FireCustomMissile("RedFlareSpawn",-5,0,0,0)
       // TNT1 A 0 A_PlaySound ("DSRFIRE")
		TNT1 A 0 BRIGHT A_FireCustomMissile("Alerter")
		TNT1 A 0 A_FireCustomMissile("GrenadeMissileBreaksGlass", 0, 1, 0, -10)
		AMPF A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLF A 0
		"####" A 1 BRIGHT A_FireCustomMissile("ShortGrenade", 0, 1, 0, -10) //rocket2
		"####" A 0 A_Takeinventory("AMLRounds",1)
        //TNT1 A 0 ACS_Execute(374, 0, 0, 0, 0)
		"####" A 0 A_Recoil(5)
		"####" A 0 A_PlaySound("Weapons/GrenadeFire", 5)
		"####" BCD 1 BRIGHT
        "####" E 1 A_SetPitch(-8.0 + pitch)
        //"####" BCD 2 A_SetPitch(2.0 + pitch)
		//"####" EF 2 A_SetPitch(1.0 + pitch)
		AMPG A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLG A 0
		"####" BCD 2 A_SetPitch(2.0 + pitch)
		"####" EF 2 A_SetPitch(1.0 + pitch)
        "####" A 0
        "####" A 0 A_Refire
        Goto Ready
		
	AltFire:
        AMPG A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLG A 0
		"####" A 0 A_JumpIfInventory("AMLRounds",1,2)
		Goto Reload
		"####" AAAA 0
		"####" A 0 A_TakeInventory ("HasUnloadedRL", 1)
		"####" A 0 A_PlaySound("Weapons/GrenadeOpen")
		"####" A 4
		"####" A 0 A_PlaySound("Weapons/GrenadeLoad")
		"####" A 4
		"####" A 0 A_PlaySound("Weapons/GrenadeClose")
		"####" A 8
		"####" A 0 A_ReFire
  
	AltHold:
	    AMPG A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLG A 0
		"####" A 0 A_JumpIfInventory("Reloading",1,"GrenadeOut")
		"####" A 0 A_PlaySound("BEP")
		"####" A 1
		
		"####" A 0 A_JumpIfInventory("Reloading",1,"GrenadeOut")
		"####" A 1
		
		"####" A 0 A_JumpIfInventory("Reloading",1,"GrenadeOut")
		"####" A 1
		
				
		"####" A 0 A_ReFire

		// Let Fly --------------------------------------------------------------------------

		"####" A 0 A_FireCustomMissile("RedFlareSpawn",-5,0,0,0)
		"####" AAAAAA 0 BRIGHT A_FireCustomMissile("ShotgunParticles", random(-16,16), 0, -1, random(-9,9))
		"####" A 0 BRIGHT A_FireCustomMissile("Alerter")
		
		"####" A 0 A_FireCustomMissile("GrenadeMissileBreaksGlass", 0, 1, 0, 0)
		"####" A 0 A_JumpIfInventory("IsPaladin",1,2)
        "####" A 0
		"####" A 1 BRIGHT A_FireCustomMissile("GrenadeMissile", 0, 1, 0, 0)
		"####" A 0 A_Recoil(5)
		"####" A 0 A_Takeinventory("AMLRounds",1)
		"####" A 0 A_SetPitch(-10.0 + pitch)
		"####" A 0 A_PlaySound("Weapons/GrenadeFire", 5)
		"####" BCD 1 BRIGHT
        "####" E 1 A_SetPitch(-6.0 + pitch)
        "####" BCD 2 A_SetPitch(2.0 + pitch)
		"####" EF 2
        "####" A 0
        "####" A 0 A_ClearReFire

		Goto Ready

	
	
		
	GrenadeOut:
	    AMPF A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLF A 0
		TNT1 AAAA 0
		TNT1 A 0 A_Takeinventory("Reloading",1)
       	TNT1 A 0 A_ClearReFire
		TNT1 A 0 A_PlaySound("Weapons/GrenadeOpen")
		AMLG A 4
		TNT1 A 0 A_PlaySound("Weapons/GrenadeLoad")
		AMLG A 4
		TNT1 A 0 A_PlaySound("Weapons/GrenadeClose")
		AMLG A 8
		//TNT1 A 8 A_PlaySound("RLANDRAW")
		TNT1 A 0 A_Takeinventory("Reloading",1)
        Goto Ready
		


    Reload:
	    AMPG A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLG A 0
		"####" A 0 A_TakeInventory ("HasUnloadedRL", 1)
		"####" A 0 //A_WeaponReady
		"####" A 0 A_Takeinventory("Reloading",1)
        "####" A 0 A_JumpIfInventory("AMLRounds",6,"NoNeedToReload")
        "####" A 0 A_JumpIfInventory("AmmoRocket",1,3)
        Goto Ready
        "####" AAAA 0
        "####" A 0 A_PlaySound("Reload")
		"####" A 0 A_SetAngle(-2 + angle)
        "####" A 0 A_SetPitch(+2 + pitch)
		AMPR A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLR A 0
        "####" ABCDDE 1 
        "####" A 0 A_FireCustomMissile("RocketCaseSpawn",-30,0,-4,-4)
        "####" EFFGG 1
		"####" A 0 A_SetAngle(+2 + angle)
        "####" A 0 A_SetPitch(-2 + pitch)
		"####" HHIIJJKLM 1
		"####" A 0 A_SetAngle(+1 + angle)
        "####" MMMNOP 1
		"####" A 0 A_SetAngle(-1 + angle)
		"####" Q 3
		"####" PR 1
		AMPG A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLG A 0
		"####" DEF 2
		"####" A 6
		Goto FinishReload
		
		FinishReload:
		TNT1 AAAAAA 0
		TNT1 A 0 A_JumpIfInventory("AMLRounds",6,"NoNeedToReload")
		TNT1 A 0 A_JumpIfInventory("AmmoRocket",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		"####" A 0 A_TakeInventory ("HasUnloadedRL", 1)
		TNT1 A 0 A_Giveinventory("AMLRounds",1)
		TNT1 A 0 A_Takeinventory("AmmoRocket",1)
		Goto FinishReload
		
		NoNeedToReload:
        AMPG A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLG A 0
		"####" A 0 A_TakeInventory ("HasUnloadedRL", 1)
		"####" A 1 A_Refire
        Goto Ready

Unload:
	    AMPG A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLG A 0
		"####" A 0 A_JumpIfInventory("AMLRounds",1,2)
		Goto ReadyNoAMmo
		"####" AA 3
		
		"####" A 1 A_WeaponReady(WRF_NOFIRE)
		"####" A 0 A_Takeinventory("Unloading",1)
        "####" A 0 A_JumpIfInventory("AmmoRocket",1,3)
        Goto Ready
        "####" AAAA 0
		
        "####" A 0 A_PlaySound("Reload")
		AMPR A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLR A 0
        "####" ABCDE 1 
        "####" EFGGG 1
		"####" HI 1
		"####" A 0 A_Giveinventory("HasUnloadedRL",1)
		
		
	FinishUnload:
		TNT1 AAAAAA 0
		AMPG A 0 A_JumpIfInventory("IsPaladin",1,2)
        AMLG A 0
		"####" A 0 A_JumpIfInventory("AMLRounds",1,3)
		Goto ReadyNoAMmo
        TNT1 AAAA 0
		TNT1 A 0 A_Takeinventory("AMLRounds",1)
		TNT1 A 0 A_Giveinventory("AmmoRocket",1)
		Goto FinishUnload
		
		TNT1 AAAAAAAAAA 0
		Goto ReadyNoAMmo

 
	}
}

//Actor RocketRounds: Inventory
//{
//inventory.maxamount 6
//}

ACTOR AMLRounds : Ammo
{
   Inventory.Amount 0
   Inventory.MaxAmount 6
   Ammo.BackpackAmount 0
   Ammo.BackpackMaxAmount 6
   Inventory.Icon "LAUNC0"
}